<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/templateList.xhtml">

	<ui:define name="body">
	
		<h2 class="title"><a href="#">Gerenciar Empresas</a></h2><br/>

			<h:form id="listEmpresasForm">
		        <rich:dataTable value="#{manterEmpresaController.listaEmpresas}" var="_emp"
		        	rows="10"
		        	id="tabelaEmpresas">
		        
		        	<rich:column>
		        		<f:facet name="header">
		        			<h:selectBooleanCheckbox value="#{manterEmpresaController.selecionadoTodos}">
		        				<a:support event="onchange" action="#{manterEmpresaController.selecionaTodos}"
		        					reRender="tabelaEmpresas"/>
		        			</h:selectBooleanCheckbox>	
		        		</f:facet>
		        		<h:selectBooleanCheckbox value="#{_emp.selecionado}"/>
		        	</rich:column>
		        	
		        	<rich:column filterBy="#{_emp.dscRazaoSocial}" filterEvent="onkeyup">
		        		<f:facet name="header">Razão Social</f:facet>
		        		<h:outputText value="#{_emp.dscRazaoSocial}"/>
		        		<a:queue ignoreDupResponses="true"/>
		        		<rich:toolTip followMouse="true" direction="top-right" showDelay="500"
							styleClass="tooltip" layout="block">
							<span style="white-space: nowrap">
								<table>
									<tr>
										<td>
											<strong>CNPJ:</strong><h:outputText value="#{_emp.dscCnpj}" converter="conversorCnpj"/><br/> 
											<strong>Data de Cadastro:</strong><h:outputText value="#{_emp.dtaCadastro}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/>
											<strong>Data de Validade:</strong><h:outputText value="#{_emp.dtaValidade}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/> 
											<strong>Telefone 1:</strong><h:outputText value="#{_emp.dscTelefone1}" /><br/>
											<strong>Telefone 2:</strong><h:outputText value="#{_emp.dscTelefone2}" /><br/>
											<strong>Endereço:</strong><h:outputText value="#{_emp.dscEndereco}" /><br/>
											<strong>Cidade:</strong><h:outputText value="#{_emp.dscCidade}" /><br/>
											<strong>UF:</strong><h:outputText value="#{_emp.dscUf}" /><br/>
											<strong>CEP:</strong><h:outputText value="#{_emp.dscCep}" converter="conversorCEP"/><br/>
											<strong>Nome Responsável:</strong><h:outputText value="#{_emp.dscNomeResponsavel}"/><br/>
											<strong>CPF Responsável:</strong><h:outputText value="#{_emp.dscCpfResponsavel}" converter="conversorCPF"/>
										</td>
									</tr>
								</table> 
							</span>
						</rich:toolTip>
		        	</rich:column>
		        	
		        	<rich:column filterBy="#{_emp.dscNomeFantasia}" filterEvent="onkeyup">
		        		<f:facet name="header">Nome Fantasia</f:facet>
		        		<h:outputText value="#{_emp.dscNomeFantasia}"/>
		        		<a:queue ignoreDupResponses="true"/>
		        		<rich:toolTip followMouse="true" direction="top-right" showDelay="500"
							styleClass="tooltip" layout="block">
							<span style="white-space: nowrap">
								<table>
									<tr>
										<td>
											<strong>CNPJ:</strong><h:outputText value="#{_emp.dscCnpj}" converter="conversorCnpj"/><br/> 
											<strong>Data de Cadastro:</strong><h:outputText value="#{_emp.dtaCadastro}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/>
											<strong>Data de Validade:</strong><h:outputText value="#{_emp.dtaValidade}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/> 
											<strong>Telefone 1:</strong><h:outputText value="#{_emp.dscTelefone1}" /><br/>
											<strong>Telefone 2:</strong><h:outputText value="#{_emp.dscTelefone2}" /><br/>
											<strong>Endereço:</strong><h:outputText value="#{_emp.dscEndereco}" /><br/>
											<strong>Cidade:</strong><h:outputText value="#{_emp.dscCidade}" /><br/>
											<strong>UF:</strong><h:outputText value="#{_emp.dscUf}" /><br/>
											<strong>CEP:</strong><h:outputText value="#{_emp.dscCep}" converter="conversorCEP"/><br/>
											<strong>Nome Responsável:</strong><h:outputText value="#{_emp.dscNomeResponsavel}"/><br/>
											<strong>CPF Responsável:</strong><h:outputText value="#{_emp.dscCpfResponsavel}" converter="conversorCPF"/>
										</td>
									</tr>
								</table> 
							</span>
						</rich:toolTip>
		        	</rich:column>
		        	
		        	<rich:column filterBy="#{_emp.dscEmail}" filterEvent="onkeyup">
		        		<f:facet name="header">E-mail</f:facet>
		        		<h:outputText value="#{_emp.dscEmail}"/>
		        		<a:queue ignoreDupResponses="true"/>
		        		<rich:toolTip followMouse="true" direction="top-right" showDelay="500"
							styleClass="tooltip" layout="block">
							<span style="white-space: nowrap">
								<table>
									<tr>
										<td>
											<strong>CNPJ:</strong><h:outputText value="#{_emp.dscCnpj}" converter="conversorCnpj"/><br/> 
											<strong>Data de Cadastro:</strong><h:outputText value="#{_emp.dtaCadastro}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/>
											<strong>Data de Validade:</strong><h:outputText value="#{_emp.dtaValidade}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/> 
											<strong>Telefone 1:</strong><h:outputText value="#{_emp.dscTelefone1}" /><br/>
											<strong>Telefone 2:</strong><h:outputText value="#{_emp.dscTelefone2}" /><br/>
											<strong>Endereço:</strong><h:outputText value="#{_emp.dscEndereco}" /><br/>
											<strong>Cidade:</strong><h:outputText value="#{_emp.dscCidade}" /><br/>
											<strong>UF:</strong><h:outputText value="#{_emp.dscUf}" /><br/>
											<strong>CEP:</strong><h:outputText value="#{_emp.dscCep}" converter="conversorCEP"/><br/>
											<strong>Nome Responsável:</strong><h:outputText value="#{_emp.dscNomeResponsavel}"/><br/>
											<strong>CPF Responsável:</strong><h:outputText value="#{_emp.dscCpfResponsavel}" converter="conversorCPF"/>
										</td>
									</tr>
								</table> 
							</span>
						</rich:toolTip>
		        	</rich:column>
		        	
		        	<rich:column rendered="#{identity.hasRole('GERENCIAR_EMPRESAS_GRAVAR')}">
		        		<f:facet name="header"></f:facet>
		        		<h:commandLink value="EDITAR"
		        			action="#{manterEmpresaController.editar(_emp)}"/>
		        	</rich:column>
		        </rich:dataTable>
		        <rich:datascroller for="tabelaEmpresas"/>
		        
		        <br/>
	            <div class="actionButtons">
		        	<h:commandButton id="remove" value="Excluir" action="#{manterEmpresaController.excluir}"
		        		rendered="#{identity.hasRole('GERENCIAR_EMPRESAS_EXCLUIR')}"	
		        		onclick="javascript:if(!confirm('Tem certeza que deseja excluir?'))return false;"/>
		        	<h:commandButton id="new" value="Novo" action="#{manterEmpresaController.novaEmpresa()}"
		        		rendered="#{identity.hasRole('GERENCIAR_EMPRESAS_GRAVAR')}"/>
		        </div>
	        </h:form>

 </ui:define>
</ui:composition>
